/**
 * Entry point for Programmer's Notepad TextUtil Plugin
 */

#include "stdafx.h"
#include "plugin.h"

_Context g_Context;

bool __stdcall pn_init_extension(int iface_version, extensions::IPN* pn)
{
	if(iface_version != PN_EXT_IFACE_VERSION)
		return false;

	g_Context.PN = pn;

	// Do your initialisation stuff here...

	// You probably want to store pn somewhere, and hook up to some app events. These
	// events will tell you when documents are opened, closed, etc.
	
	// extensions::IAppEventSinkPtr sink(new MyEventSink());
	// pn->AddEventSink(sink);

	// You can control various basic functionality right from the pn instance:

	// pn->NewDocument(NULL);
	// pn->OpenDocument("Sample.cpp", "java"); // Open Sample.cpp with the java scheme
	// pn->OpenDocument("Sample.cpp", NULL);   // Open Sample.cpp with the default scheme for *.cpp
	// pn->GetCurrentDocument()->GetFileName();

	// Documents have events too:

	// extensions::IDocumentEventSinkPtr docSink(new DocEvents(pn->GetCurrentDocument()));
	// pn->GetCurrentDocument()->AddEventSink(docSink);
	// extensions::IDocumentEventSinkPtr editSink(new EditEvents(pn->GetCurrentDocument()));
	// pn->GetCurrentDocument()->AddEventSink(editSink);

	extensions::IMenuItems* menu = MakeCommands();
	pn->AddPluginMenuItems(menu);
	delete menu;

	return true;
}

void __declspec(dllexport) __stdcall pn_get_extension_info(PN::BaseString& name, PN::BaseString& version)
{
	name = "Text Utilities";
	version = "0.2";
}

void __declspec(dllexport) __stdcall pn_exit_extension()
{

}